package com.schoolcloud.system.controller;

import com.schoolcloud.common.model.R;
import com.schoolcloud.system.dto.UserAuthRoleDTO;
import com.schoolcloud.system.service.SysUserRoleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/user/role")
@RequiredArgsConstructor
public class SysUserRoleController {
    private final SysUserRoleService sysUserRoleService;
    @PostMapping("/auth")
    public R addUserRole(UserAuthRoleDTO dto){
        sysUserRoleService.addUserRole(dto);
        return R.ok();
    }
    @GetMapping("/userId/{userId}")
    public R<List<Integer>> getUserRoleIdByUserId(@PathVariable Integer userId){
       List<Integer> roleIds = sysUserRoleService.getUserRoleByUserId(userId);
        return R.ok(roleIds);
    }
}
